package kingAI.core;

import java.io.PrintStream;

/**
 * Defines a player.
 * Can be AI or Human.
 * 
 * @author Equilibrium
 * @version 1.0
 */
public abstract class Player {
	private Hand hand;
	private String name;
//	private Hand cardsOut;
	private int points;
//	private Contract currentContract;
	
	/**
	 * The information output stream of this player.
	 */
	protected PrintStream out;
	
	public Player(String name, PrintStream out){
		hand=new Hand();
		points=0;
		this.name = name;
		this.out = out;
	}
	
	public int getPoints(){
		return points;
	}
	public void changePoints(int dp){
		points+=dp;
	}
	public void printHand(){
		System.out.println(name+"'s hand:");
		System.out.println(hand.toString());
	}
	public Hand getHand(){
		return hand;
	}
	public String getName(){
		return name;
	}
	
	/**
	 * Empties this player's hand.
	 */
	public void flushHand(){
		for(int i=0;i<15;i++){
			hand.diamonds[i]=false;
			hand.hearts[i]=false;
			hand.spades[i]=false;
			hand.clubs[i]=false;
		}
	}
	
	//TODO: determine input parameters for Player.chooseGame
	public abstract Contract chooseContract();
	
	//TODO: determine input parameters for Player.play
	public abstract Card play();
	
	/**
	 * Adds the card to this player's hand.
	 * 
	 * @param card The card to be given to this player.
	 */
	public void giveCard(Card card){
		if(card.suit==Suit.Diamonds)
			hand.diamonds[card.rank]=true;
		else if(card.suit==Suit.Hearts)
			hand.hearts[card.rank]=true;
		else if(card.suit==Suit.Spades)
			hand.spades[card.rank]=true;
		else
			hand.clubs[card.rank]=true;
	}
	
	//TODO: determine whether startAGame method is necessary
	//public abstract void startAGame(GameType gameType);
	
	//TODO: TEST; DELETE THIS:
	public abstract void TEST();
}
